

*** Cox Proportional Hazard model 


*** Import the dataset
****************************
*****************************

clear
set maxvar 100000

use "C:\Users\jrichman\OneDrive - Old Dominion University\GraduateStudents\Imran\Bits_data_02Aug_2025.dta"

stset Year, id(dyad_combine)  failure(Bit_agreement) origin(time atrisk)

*****************************MODEL 1********************************************
********************************************************************************
********************************************************************************
***Simplest survival model contains variables for all hypotheses without any covariates

stcox is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag 

// this is the full test of hypothesis -- do we have evidence for significant effect overall from being in a failed multilateral episode?
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag  



*****************************MODEL 2********************************************
********************************************************************************
********************************************************************************

// adding in learning variables

stcox Cum_bits_byYear is_dyad_in_multilateral learning dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag 

// this is the full test of hypothesis -- do we have evidence for significant effect overall from being in a failed multilateral episode?
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag






****************************MODEL 3*********************************************
********************************************************************************
********************************************************************************
*** Model contains contains variables for all hypotheses with full set of covariates

generate Imfcredit_hostm = Imfcredit_host
replace Imfcredit_hostm = 0 if Imfcredit_host == .
generate Imfcredit_hostd = .
replace Imfcredit_hostd = 0 if Imfcredit_hostm == 0
replace Imfcredit_hostd = 1 if Imfcredit_hostm > 0
generate lnGDP_constant_host = ln(GDP_constant_host)



stcox Cum_bits_byYear is_dyad_in_multilateral learning lnGDP_constant_host GDP_growth_host FDI_inflow_hostLagOneYear FDI_outflow_home colony common_official_lang shortTermDebt_host comcol  trade_volume Imfcredit_hostd dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag

test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag


 


 
**********Model 4 ********************

 

*** linear interpolation to fill in missing values of legal property rights variables

**** using the carryforward option to avoid contaminating past values with future values. 
**** search carryforward to install

bysort dyad_combine (Year): carryforward Legal_propertyRights_host, gen(Legal_propertyRights_host2)


 ///  adding OECD and WTO dyad dummy variable to the rest of the variables...
 generate OECDdyad = 0
 replace OECDdyad = 1 if OECD_member_Country1 == 1 & OECD_member_Country2 == 1 
 generate GATT_WTOdyad = 0
 replace GATT_WTOdyad = 1 if GATT_WTO_country_1 == 1 & GATT_WTO_country_2 == 1 


stcox Cum_bits_byYear is_dyad_in_multilateral learning lnGDP_constant_host GDP_growth_host FDI_inflow_hostLagOneYear FDI_outflow_home colony common_official_lang shortTermDebt_host comcol  trade_volume Imfcredit_hostd dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag pol_instability_host Legal_propertyRights_host2 GATT_WTOdyad OECDdyad
 
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag





 
*********Runing the same models with fixed effects**********************
**********************************************************************************
***********************Model 1 with fixed effects**************************

 
 // fixed effects by country model 1
 
stcox is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag i.ccode_1 i.ccode_2


// this is the full test of hypothesis -- do we have evidence for significant effect overall from being in a failed multilateral episode?
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag


//fixed effects version of model 2

stcox Cum_bits_byYear is_dyad_in_multilateral learning dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag i.ccode_1 i.ccode_2  

// this is the full test of hypothesis -- do we have evidence for significant effect overall from being in a failed multilateral episode?
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag


//fixed effects version of model 3

stcox Cum_bits_byYear is_dyad_in_multilateral learning lnGDP_constant_host GDP_growth_host FDI_inflow_hostLagOneYear FDI_outflow_home colony common_official_lang shortTermDebt_host comcol  trade_volume Imfcredit_hostd  dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag i.ccode_1 i.ccode_2
 
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag

*** fixed effects version of model 4
stcox is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag Cum_bits_byYear learning lnGDP_constant_host GDP_growth_host FDI_inflow_hostLagOneYear FDI_outflow_home colony common_official_lang shortTermDebt_host comcol  trade_volume Imfcredit_hostd pol_instability_host Legal_propertyRights_host2 GATT_WTOdyad OECDdyad i.ccode_1 i.ccode_2
 
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag



*********Runing the same models assuming weibull distribution**********************
**********************************************************************************
***********************Model 1 with weibull distribution**************************

streg is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag, distribution(weibull)

test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag

**********************************************************************************
***********************Model 2 with weibull distribution**************************
streg Cum_bits_byYear is_dyad_in_multilateral learning dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag, distribution(weibull)

test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag


*********************************************************************************
***********************Model 3 with weibull distribution*************************
streg Cum_bits_byYear is_dyad_in_multilateral learning lnGDP_constant_host GDP_growth_host FDI_inflow_hostLagOneYear FDI_outflow_home colony common_official_lang shortTermDebt_host comcol  trade_volume Imfcredit_hostd dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag, distribution(weibull)

test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag

**** Model 4 with weibull distribution*************************

streg Cum_bits_byYear is_dyad_in_multilateral learning lnGDP_constant_host GDP_growth_host FDI_inflow_hostLagOneYear FDI_outflow_home colony common_official_lang shortTermDebt_host comcol  trade_volume Imfcredit_hostd dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag pol_instability_host Legal_propertyRights_host2 GATT_WTOdyad OECDdyad, distribution(weibull)
 
test is_dyad_in_multilateral dyad_Multi_1yrlag dyad_Multi_2yrlag dyad_Multi_3yrlag dyad_Multi_4yrlag
